import { Component, Vue, Watch } from 'vue-property-decorator';
import {
    pick
} from "lodash"
import userCookies from "@/utils/data/cookies";
@Component({
})
export class mixinTableTree extends Vue {
    dataStore: any = {
        proxy: {
            autoLoad: false
        }
    };
    parkName: string = "";

    created() {
        (this as any).getTree();
        this.parkName = userCookies.get("yard_name");
    }

    treeValueName: string = "value";
    @Watch("treeData", { immediate: true })
    updateTreeData(v: any) {
        const me = this as any;
        me.$nextTick(() => {
            if (v.length) {
                // 默认选中第一项
                const item = v[0];
                me.onNodeClick(item);
                me.$refs.tree.setCurrentKey(item[me.treeValueName]);
            }
        });
    }


    selectItem: any = null;
    pickList: any = []
    // 菜单被点击时
    onNodeClick(data: any) {
        const me = this as any;
        me.lodaByDefaultParams(pick(data, me.pickList));
        me.selectItem = data;
    }


}
